
<script>
import "../assets/index.css";
import InputMsg from "../components/InputMsg";
export default {
  name: "add",
  data() {
    return {
      userMsg: {},
    };
  },
  methods: {
    addUser(e) {
      let {username,age,hobby}=e
      this.$Spin.show({
        render: (h) => {
          return h("div", [
            h("Icon", {
              class: "demo-spin-icon-load",
              props: {
                type: "ios-loading",
                size: 18,
              },
            }),
            h("div", "Loading"),
          ]);
        },
      });
      this.$axios
        .post("/users", {username,age,hobby})
        .then((data) => {
          this.$Spin.hide();
          if (data.data.code == 0) {
            this.$Message.success("创建成功");
          } else {
            this.$Message.error("创建失败");
          }
        })
        .catch((err) => {
          // 获取失败
          console.log(err);
        });
    },
  },
  render(){
    return(
            <div class="addUser content">
      <InputMsg updataFlag={false} onGetMsg={this.addUser}></InputMsg>
      </div>
    )
  }
};
</script>
